{% extends "template/layout.html" %} {% block content %}
<style>
  .admin_default {
    margin: 20px;
  }

  .layui-body {
    overflow-y: scroll;
  }

  .backBtn {
    float: right;
  }

  .addFrom {
    margin: 20px 20px 20px 5px;
  }

  .formBtn {
    margin-left: 150px;
    margin-top: 50px;
  }

  .idItem {
    display: none;
  }

  .noticeAdd {
    width: 230px;
    height: 30px;
  }

  .addForm {
    margin-top: 30px;
    width: 650px;
    margin: auto;
  }

  #demo1 {
    width: 200px;
    height: 200px;
  }

  .notcieImg {
    display: none;
  }

  .noticeText {
    display: none;

  }
</style>

<div class="panel admin_default">
  <div class="demoTable">
    <div class="layui-inline  noticeAdd">
    </div>
    <button class="layui-btn  backBtn">返回</button>

  </div>
  <div class="addForm">
    <form class="layui-form" action="" lay-filter="detailform">
      <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
          <input type="text" name="title" required lay-verify="required" autocomplete="off" placeholder="请输入标题" class="layui-input" disabled>
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">公告类型</label>
        <div class="layui-input-block">
          <select name="noticeType" lay-filter="type" id="addChage" required lay-verify="required" disabled>
            <option value=""></option>
            <option value="图">图</option>
            <option value="文字">文字</option>
          </select>
        </div>
      </div>
      <div class="layui-form-item layui-form-text notcieImg">
        <label class="layui-form-label">图</label>
        <div class="layui-input-block">
          <div class="layui-upload">
           
            <div class="layui-upload-list">
              <img class="layui-upload-img" id="demo1">
              <p id="demoText"></p>
            </div>
          </div>
        </div>
      </div>
      <div class="layui-form-item layui-form-text   noticeText">
        <label class="layui-form-label">公告内容</label>
        <div class="layui-input-block">
          <textarea placeholder="请输入内容" class="layui-textarea" name="content" disabled></textarea>
        </div>
      </div>

      <div class="layui-form-item">
       
      </div>
    </form>
  </div>


</div>


{% endblock %} {% block footer %}

<script>
    var detailformData={};
      detailformData.title =`{{detail.title}}`;
      detailformData.id =`{{detail.id}}`;
      detailformData.content =`{{detail.content}}`;
      detailformData.img =`{{detail.img}}`;
      detailformData.noticeType =`{{detail.noticeType}}`;

  layui.use(['form', 'table', 'laydate', 'upload'], function () {
    var table = layui.table;
    var form = layui.form;
    var upload = layui.upload;
  
    //返回事件
  

    form.val('detailform', detailformData)
     
     //判断显示
       function judgeShow(){
        
      if (detailformData.noticeType === '图') {
        $('.notcieImg').show();
        $('#demo1').attr('src',   detailformData.img); //图片链接（base64）
      }
      if (detailformData.noticeType === '文字') {
        $('.noticeText').show();
      } 
       } 
       judgeShow();

    form.on('select(type)', function (data) {
      var selectVal = data.value;

      if (selectVal === '图') {
        $('.notcieImg').show();
        $('.noticeText').hide();
      }
      if (selectVal === '文字') {
        $('.notcieImg').hide();
        $('.noticeText').show();
      }
    });
    $(".backBtn").click(function () {
      window.location.href = "/notice"
    })
  });
</script>
{% endblock %}